package entry;

import java.util.HashMap;

public class Room {
    private String ID;
    private String name;
    private String hostName;
    private HashMap<MemberSocket,Boolean> members;

    public Room(){
        members = new HashMap<>();
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getHostName() {
        return hostName;
    }

    public void setHostName(String hostName) {
        this.hostName = hostName;
    }

    public HashMap<MemberSocket, Boolean> getMembers() {
        return members;
    }

    public void setMembers(HashMap<MemberSocket, Boolean> members) {
        this.members = members;
    }

    public boolean hasMember(MemberSocket member){
        if (members.containsKey(member))
            return true;
        return false;
    }

    public boolean addMember(MemberSocket member){
        if (hasMember(member))
            return false;
        members.put(member,true);
        return true;
    }

    public boolean removeMember(MemberSocket member){
        if (!hasMember(member))
            return false;
        members.remove(member);
        return true;
    }

    public boolean getStatus(MemberSocket member){
        return members.get(member);
    }

    public void setStatus(MemberSocket member, boolean status){
        members.put(member,status);
    }

    public void changeStatus(MemberSocket member){
        if (members.get(member))
            members.put(member,false);
        else
            members.put(member,true);
    }
}
